package game;

import javax.swing.*;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

//飞机游戏的主窗口
public class MyGameFrame extends JFrame {

    //窗口绘制


    @Override
    public void paint(Graphics g) {
        super.paint(g);
        Color c=g.getColor();//保存颜色
        Font f=g.getFont();//保存字体
        g.setColor(Color.cyan);//设置其他颜色
        g.drawLine(100,100,300,300);
        g.drawRect(100,100,300,300);//画长方形
        g.drawOval(100,100,300,300);//画圆
        g.fillRect(100,100,60,60);//实心长方形
        g.setColor(Color.pink);
        g.setFont(new Font("楷体",Font.BOLD,20));
        g.drawString("我是谁?",200,200);
        g.setColor(c);//变为原来的颜色
    }

    public MyGameFrame(){
        this.setTitle("李乾坤作品");
        this.setVisible(true);//使窗口可见,窗口默认是不可见的
        this.setSize(500,500);
        this.setLocation(400,100);
        //关闭窗口的同时关闭程序
        this.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                System.exit(0);//0:表示正常关闭
            }
        });
    }

}
